package site.sorghum.ddl.field;

import java.sql.JDBCType;

public class SQLServerTypeConvert extends BasicTypeConverter {
    public static final TypeConverter INSTANCE = new SQLServerTypeConvert();

    @Override
    public String convertToDatabaseType(JDBCType jdbcType) {
        if (jdbcType == null) {
            throw new IllegalArgumentException("JDBC type cannot be null");
        }

        switch (jdbcType) {
            case BOOLEAN:
                return "BIT";
            case LONGVARCHAR:
            case LONGNVARCHAR:
            case NCLOB:
            case NVARCHAR:
                return "NVARCHAR";
            case LONGVARBINARY:
                return "VARBINARY";
            case TIMESTAMP:
                return "DATETIME2";
            case TIME_WITH_TIMEZONE:
            case TIMESTAMP_WITH_TIMEZONE:
                return "DATETIMEOFFSET";
            case FLOAT:
            case DOUBLE:
                return "FLOAT";
            case NCHAR:
                return "NCHAR";
            default:
                return super.convertToDatabaseType(jdbcType);
        }
    }
}
